﻿using System;
using Gonte;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MyUtilitiesTest
{
    /// <summary>
    ///This is a test class for StringUtilsTest and is intended
    ///to contain all StringUtilsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class StringUtilsTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        [TestMethod()]
        public void StringUtilsToCamelCaseTest()
        {
            Assert.AreEqual("aField", StringUtils.ToCamelCase("AField"));
        }

        [TestMethod()]
        public void StringUtilsToCamelCaseNullTest()
        {
            Assert.AreEqual(null, StringUtils.ToCamelCase(null));
        }

        [TestMethod()]
        public void StringUtilsToPascalCaseTest()
        {
            Assert.AreEqual("AField", StringUtils.ToPascalCase("aField"));
        }

        [TestMethod()]
        public void StringUtilsToPascalCaseNullTest()
        {
            Assert.AreEqual(null, StringUtils.ToPascalCase(null));
        }

        [TestMethod()]
        public void StringUtilsReplaceTest()
        {
            StringUtils.StringReplacement[] replacements = new StringUtils.StringReplacement[2];

            StringUtils.StringReplacement repl1;
            repl1.OldString = "u";
            repl1.NewString = "a";
            replacements[0] = repl1;

            StringUtils.StringReplacement repl2;
            repl2.OldString = "k";
            repl2.NewString = "d";
            replacements[1] = repl2;

            Assert.AreEqual("dada", StringUtils.Replace("kuku", replacements));
        }

        [TestMethod()]
        public void StringUtilsReplaceNullReplacementsTest()
        {
            Assert.AreEqual("kuku", StringUtils.Replace("kuku", null));
        }

        [TestMethod()]
        public void StringUtilsMakeSingularWithSTest()
        {
            Assert.AreEqual("car", StringUtils.MakeSingular("cars"));
        }

        [TestMethod()]
        public void StringUtilsMakeSingularWithIesTest()
        {
            Assert.AreEqual("sixty", StringUtils.MakeSingular("sixties"));
        }

        [TestMethod()]
        public void StringUtilsMakeSingularWithXesTest()
        {
            Assert.AreEqual("index", StringUtils.MakeSingular("indexes"));
        }

        [TestMethod()]
        public void StringUtilsMakePluralWithSTest()
        {
            Assert.AreEqual("cars", StringUtils.MakePlural("car"));
        }

        [TestMethod()]
        public void StringUtilsMakePluralWithAsTest()
        {
            Assert.AreEqual("glasses", StringUtils.MakePlural("glass"));
        }

        [TestMethod()]
        public void StringUtilsMakePluralWithYTest()
        {
            Assert.AreEqual("sixties", StringUtils.MakePlural("sixty"));
        }

        [TestMethod()]
        public void StringUtilsMakePluralWithAyTest()
        {
            Assert.AreEqual("ways", StringUtils.MakePlural("way"));
        }
    }
}
